const express = require('express')

const app = express()

app.get(
  '/user/:id',
  function (req, res, next) {
    // req.params.id为0时 将控制权传递给下一条路由
    // next('route') 为固定写法
    if (req.params.id === '0') next('route')
    else next()
  },
  function (req, res, next) {
    res.send('regular')
  }
)

app.get('/user/:id', function (req, res, next) {
  res.send('special')
})

app.listen(3000, () => {
  console.log(`Server running at http://localhost:3000/`)
})
